home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 010 / pcube.bas (.txt) < prev    next >
Encoding:
GW-BASIC  |  1982-09-21  |  24.8 KB  |  443 lines

  1. 10  '                          RUBIK'S CUBE SIMULATOR
  2. 20  '                                 PC MAGAZINE
  3. 30  '                                 march, 1982
  4. 40  '                                karl koessel
  5. 50  SCREEN 0,1,0,0'                Text mode, color on, active page, visual page
  6. 60  COLOR 7,0,1'                   Print white on black. Border on color monitor
  7. 70  CLS'                           Clear screen. Hello...
  8. 80  KEY OFF'                       Turn off soft keys' display on line 25
  9. 90  CLEAR,,2000'                   Clear some work space
  10. 100  DEFINT A-Z'                   Variables are all integers
  11. 110  DIM HOLD(20)'                 This array has subscripts greater than 10
  12. 120  GOSUB 3240'                                      Read constants
  13. 130  GOSUB 3620'                                      Initialize variables
  14. 140  GOSUB 3680'                                      Display title page
  15. 150  GOSUB 3770'                                      Input colors of faces
  16. 160  GOSUB 600'                                       Get a new cube
  17. 170  '**************************    INPUT ROUTINES    **************************
  18. 180  '***********   First input requests a twist or command
  19. 190  GOSUB 2760'                                Find proper location
  20. 200  COLOR 23'                                  Blink ...
  21. 210  PRINT "Enter ";'                              ... beginning of input prompt
  22. 220  COLOR 7'                                   Normal foreground
  23. 230  LINE INPUT "a twist or command: ",TWIST$'  Finish prompt, no question mark
  24. 240  IF TWIST$="" THEN 190'                     Operator silent? Let's ask again
  25. 250  GOSUB 1860'                                Input received-clear input lines
  26. 260  REQ$=TWIST$'                               Copy input for testing routines
  27. 270  GOSUB 820'                                 Check for a valid command, if so
  28. 280  IF D THEN 190'                             it's done-go back to first input
  29. 290  GOSUB 910'                                 Else check for a valid twist
  30. 300  GOTO 190'                                  Loop back for next twist/command
  31. 310  '**********   Second input requests ok to proceed
  32. 320  GOSUB 2760'                                Find proper location
  33. 330  PRINT "Press [RETURN] to twist the ";'     Begin second input prompt
  34. 340  IF CLRMON THEN COLOR BR(F) ELSE COLOR 1'   Emphasize the ...
  35. 350  PRINT PLACE$(1,F);'                             ... name of the chosen face
  36. 360  COLOR 7'                                   Normal foreground
  37. 370  PRINT " face ";'                           Middle of second input prompt
  38. 380  IF CLRMON THEN COLOR BR(F) ELSE COLOR 1'   Emphasize the
  39. 390  PRINT DIRECTION$(OSO)'                            ...direction of the twist
  40. 400  COLOR 7'                                   Normal foreground
  41. 410  IF CLRMON AND BIG THEN 430'                Skip spacing?
  42. 420  PRINT SPC(13)'                             Print spaces on WIDTH 80 display
  43. 430  PRINT "or enter a new twist or command: ";'Finish second input prompt.
  44. 440  LINE INPUT "",GO$'         Line input avoids redo error if comma is entered
  45. 450  GOSUB 1860'                                Input received-clear input lines
  46. 460  IF GO$="" THEN 530'                        If blank, go finish twist, else
  47. 470  REQ$=GO$'                                  Copy input for testing routines
  48. 480  GOSUB 820'                                 Check for a command, if so do it
  49. 490  ON D GOTO 320,320,320,320,510,320,320,320,530'     and continue accordingly
  50. 500  GOSUB 910'                                 else check for a valid twist
  51. 510  RETURN'                                    Invalid 2nd input, return to 1st
  52. 520  '**********   If GO$="" then finish the twist !
  53. 530  GOSUB 2360'                                     Finish turning outer circle
  54. 540  GOSUB 2520'                                     Finish turning chosen face
  55. 550  GOSUB 1900'                                     Turn off highlight flags
  56. 560  GOSUB 2000'                                     Update `twistssofar'
  57. 570  GOSUB 1590'                                     Print new cube
  58. 580  RETURN'                                         Return to first input
  59. 590  '*******************    NEW-ING AND HELP SEQUENCES   **********************
  60. 600  GOSUB 1900'                                Turn off any highlights
  61. 610  IF CLRMON THEN WIDTH 40:BIG=-1'            Set to WIDTH 40. Set big flag on
  62. 620  IF NOT BIG AND D=8 THEN RETURN'            HELP is already on the screen
  63. 630  GOSUB 2790'                                Clear screen, print instructions
  64. 640  IF D<>8 THEN GOSUB 2610'                   If not HELP, reinitialize cubies
  65. 650  IF NOT BIG THEN 690'                       WIDTH 80 display skips waiting
  66. 660  GOSUB 3020'                                Wait routine for WIDTH 40
  67. 670  CLS'                                       Clear screen
  68. 680  GOSUB 3040'                                Print title on line 25
  69. 690  GOSUB 1290'                                Reprint display
  70. 700  RETURN' If NEW, return to 1st input. If HELP, return to what you were doing
  71. 710  '********************    TURN INPUT INTO UPPER CASE    ********************
  72. 720  RQ$=""'                                     Blank new (upper case) string
  73. 730  FOR K=1 TO LEN(REQ$)'                       For each character of input
  74. 740      RK$=MID$(REQ$,K,1)'                     Set a character
  75. 750      IF RK$="'" THEN 770'                    If prime, skip character change
  76. 760      RK$=CHR$((ASC(RK$) AND 95))'            Change to upper case character
  77. 770      RQ$=RQ$+RK$'                            Add character to new string
  78. 780  NEXT
  79. 790  REQ$=RQ$'                                   Set old string to new string
  80. 800  RETURN'                                     All uppercase, ready to check
  81. 810  '*******************    TO CHECK FOR VALID COMMAND   **********************
  82. 820  GOSUB 720'                                  Convert input to upper case
  83. 830  D=0'                                        Valid command flag set to `no'
  84. 840  FOR DMI=1 TO 9'                             Check for valid command. If so,
  85. 850      IF LEFT$(REQ$,LEN(DM$(DMI)))=DM$(DMI) THEN D=DMI'  ...set flag to `yes'
  86. 860  NEXT
  87. 870  IF D>0 AND D<4 THEN DM=D-1'                 If display type, set type flag
  88. 880  ON D GOSUB 1590,1590,1590,1380,600,1210,2040,610,1350'Do it ...
  89. 890  RETURN'                                                    ...and/or return
  90. 900  '*******************    TO CHECK FOR VALID TWIST   ************************
  91. 910  GOSUB 1900'                      First turn off highlights that may be on
  92. 920  '*********   Then check if 2nd character valid and input length =2 or less
  93. 930  IF MID$(REQ$,2,1)=""OR MID$(REQ$,2,1)="'"AND LEN(REQ$)<3 THEN 960
  94. 940  GOTO 1020'                       Invalid input
  95. 950  '*********   Check first character of input for a valid twist
  96. 960  F=0'                             Deselect face
  97. 970  FOR W=1 TO LEN(T$)'              If twist is valid, set F to face number...
  98. 980      IF LEFT$(REQ$,1)=MID$(T$,W,1) THEN F=W:TWIST$=REQ$' ...and reset TWIST$
  99. 990  NEXT
  100. 1000  IF F THEN 1100'                 If face valid, go to prepare for 2nd input
  101. 1010  '*********   Invalid input!
  102. 1020  GOSUB 2760'                     Locate prompt line, print message
  103. 1030  PRINT "Input ";:COLOR 23:PRINT "NOT";:COLOR 7:PRINT " recognized"
  104. 1040  PRINT "    One moment please..."
  105. 1050  GOSUB 1590'                     Reprint display without highlights
  106. 1060  GOSUB 1860'                     Clear input prompt lines
  107. 1070  RETURN'                         Restart input
  108. 1080  '********************   PREPARE THE SELECTED TWIST   *********************
  109. 1090  '*********   Find direction, set offsets for inner & outer circular arrays
  110. 1100  IF MID$(REQ$,2,1)="'" THEN OSO=2:OSI=1 ELSE OSO=0:OSI=5
  111. 1110  '*********   Then, for the outer circle ...
  112. 1120  GOSUB 2200'                     Decode array pointers
  113. 1130  GOSUB 2260'                     Set holding cells, turn highlight flags on
  114. 1140  '**********   Then for the chosen face,
  115. 1150  GOSUB 2460'                     Set holding cells, turn highlight flags on
  116. 1160  '**********   Preparation done ...
  117. 1170  IF SKIP THEN 530'               If SKIP, no 2nd input, go finish twist now
  118. 1180  GOSUB 1590'                     Reprint display with highlights
  119. 1190  GOTO 320'                       Go to second input
  120. 1200  '********************    THOSE USING COLOR CAN CHANGE WIDTH   ************
  121. 1210  IF NOT CLRMON THEN 1330'         This routine is for color monitors only
  122. 1220  BIG=NOT BIG'                     Reverse big flag. -1=WIDTH 40, 0=WIDTH 80
  123. 1230  IF BIG THEN WIDTH 40:GOTO 1260'  Make the change to WIDTH 40, skip to 1260
  124. 1240  WIDTH 80'                        Make the change to WIDTH 80
  125. 1250  GOSUB 2790'                      For WIDTH 80, print instructions
  126. 1260  GOSUB 1290'                      Display reprinting routine
  127. 1270  RETURN'                          Continue with what you were doing before
  128. 1280  '********************    DISPLAY REPRINTING ROUTINE    *******************
  129. 1290  IF BIG THEN GOSUB 3060'     Input list for WIDTH 40 display
  130. 1300  GOSUB 1390'                 Reprint labels or blanks without changing flag
  131. 1310  GOSUB 1590'                 Reprint the cube in the new width
  132. 1320  IF NOT BIG THEN GOSUB 2040' Reprint twists so far without adding a twist
  133. 1330  RETURN'                     Return to input
  134. 1340  '********************    REVERSE SKIP FLAG     ***************************
  135. 1350  SKIP=NOT SKIP'              -1=SKIP ON, 0=SKIP OFF. When on, program skips
  136. 1360  RETURN'                                  second input (request to proceed)
  137. 1370  '********************    LABELS ON/OFF ROUTINE    ************************
  138. 1380  LABEL = NOT LABEL'          Reverse label flag. -1=LABELS ON, 0=LABELS OFF
  139. 1390  FOR FA=1 TO 6'                                    For each face
  140. 1400      IF BIG THEN LOCATE XBL(FA),YBL(FA):GOTO 1420' Locate for WIDTH 40 or
  141. 1410      LOCATE X(FA)+2,Y(FA)-1'                       Locate under each face &
  142. 1420      IF NOT LABEL GOTO 1460'                       If labels are wanted off
  143. 1430      IF CLRMON THEN COLOR BR(FA) ELSE COLOR 1'     Emphasize (face's color)
  144. 1440      PRINT PLACE$(1,FA);'                          Print name of face
  145. 1450      GOTO 1470'                                    Otherwise...
  146. 1460      PRINT SPC(5);'                                Print blanks over label
  147. 1470  NEXT
  148. 1480  IF NOT BIG THEN 1570'                             WIDTH 80 display is done
  149. 1490  FOR XBL=1 TO 2'                                   `Front' face has pointer
  150. 1500      LOCATE XBL+4,19-XBL'                          between face and label
  151. 1510      IF NOT LABEL THEN GOTO 1540'                  If labels are wanted off
  152. 1520      COLOR BR(3)'                                  Color of front face
  153. 1530      PRINT "/";'                                   Make pointer of slashes
  154. 1540      PRINT " "'                                    or blank out the slashes
  155. 1550  NEXT
  156. 1560  COLOR 7'                                          Normal foreground
  157. 1570  RETURN'                                           To what you were doing
  158. 1580  '************************    CUBE PRINTING ROUTINE    ********************
  159. 1590  DB=1:DUB=0'                        Initialize display formatting variables
  160. 1600  IF BIG THEN DB=2'                  Double this variable for WIDTH 40
  161. 1610  FOR FA=1 TO 6'                     For each face
  162. 1620  FOR P=0 TO 8'                      For each cubie on this face
  163. 1630  IF BIG THEN FOR DUB=0 TO 1'        To square cubie WIDTH 40 prints 2 lines
  164. 1640      LOCATE X(FA)+XOF(P)*DB+DUB-REL(FA)*BIG,Y(FA)+YOF(P)+RELY(FA)*BIG'Where
  165. 1650      BR=BR(FIX(CUBIE(FA,P,1)\10))'                     Set background color
  166. 1660      IF BR THEN COLOR CUBIE(FA,P,2)*-16,BR:GOTO 1680'  Blink foreground?
  167. 1670      IF CUBIE(FA,P,2) THEN COLOR 0,7 ELSE COLOR 7,0'   Turn on highlights?
  168. 1680      IF DUB THEN PRINT "  ";:GOTO 1710'                Bottom half of cubie
  169. 1690      IF DM THEN PRINT USING "\\"; CUBIE$(FA,P,DM);                                         ELSE PRINT USING "##"; CUBIE(FA,P,1);'   Print proper type cubie
  170. 1700  '******************   These lines tidy display as colors/highlights change
  171. 1710      ON P+1 GOTO 1730,1720,1720,1800,1800,1800,1740,1740,1730'  Nine cubies
  172. 1720      ND=1:GOTO 1760'                        Set the `NextDoor' variable for
  173. 1730      ND=4:GOTO 1760'                         six of them so following lines
  174. 1740      ND=-1:GOTO 1760'                        can compare neighboring cubies
  175. 1750  '                Find proper colors for each side of spaces between cubies
  176. 1760      IF BR THEN COLOR BR,BR(FIX(CUBIE(FA,(P+ND) MOD 12,1)\10)) ELSE 1780
  177. 1770      PRINT CHR$(221);:GOTO 1800'    Left half one color, right half another
  178. 1780      IF CUBIE(FA,P,2)=CUBIE(FA,(P+ND) MOD 12,2) THEN 1790 ELSE COLOR 7,0
  179. 1790      PRINT " ";'                    Single space lit or not, for monochrome
  180. 1800  IF BIG THEN NEXT'                  WIDTH 40 prints 2 lines to square cubie
  181. 1810  NEXT
  182. 1820  NEXT
  183. 1830  COLOR 7,0'                                Normalize foreground, background
  184. 1840  RETURN
  185. 1850  '************************    CLEAR PROMPT/INPUT LINES    *****************
  186. 1860  GOSUB 2760'                     Find proper location (differs on WIDTH 40)
  187. 1870  PRINT "One moment, please..."SPC(79)SPC(39)SPC(21)'   Clears lines 15 & 16
  188. 1880  RETURN'                                If WIDTH 40 clears line 19, 20 & 21
  189. 1890  '************************    TURN OFF HIGHLIGHT FLAGS    *****************
  190. 1900  FOR J=1 TO 4'                Four faces touch the chosen face and have ...
  191. 1910      FOR K=1 TO 3'            Three consecutive cubies touching chosen face
  192. 1920          CUBIE(FACE(J),((POSITION(J)+K-2) MOD 8)+1,2)=0'  Turn highlight...
  193. 1930      NEXT'                                                   ...flags `off'
  194. 1940  NEXT
  195. 1950  FOR P=1 TO 8'                All cubies on chosen face except the center
  196. 1960      CUBIE(F,P,2)=0'          Turn highlight flags `off'
  197. 1970  NEXT
  198. 1980  RETURN
  199. 1990  '************************    KEEP TRACK OF TWISTS    *********************
  200. 2000  TWISTSSOFAR$(AT)=TWISTSSOFAR$(AT)+TWIST$+" "'   Add valid twist to records
  201. 2010  IF LEN(TWISTSSOFAR$(AT))>36 THEN AT=AT+1'  Keeps 2 letter twists on 1 line
  202. 2020  IF BIG THEN RETURN'                        WIDTH 40 doesn't print new list
  203. 2030  '************************    PRINT LIST OF TWISTS SO FAR    **************
  204. 2040  LOCATE 18,1'                               Begin at bottom third of screen
  205. 2050  IF BIG THEN PRINT'                         Down 1 more line for WIDTH 40
  206. 2060  COLOR 1'                                   Emphasize list of twists header
  207. 2070  PRINT TWISTSSOFAR$(0);'                    Print header
  208. 2080  COLOR 7'                                   Normal foreground
  209. 2090  PRINT SPC(13)'                             Put space between header & list
  210. 2100  FOR K=1 TO AT'                             For each half line of twists
  211. 2110      PRINT TWISTSSOFAR$(K);'                Print 1st half line. If not big
  212. 2120      IF NOT BIG THEN PRINT TWISTSSOFAR$(K+1);:K=K+1'    Print 2nd half line
  213. 2130      PRINT'                                 Linefeed before end of WIDTH
  214. 2140  NEXT
  215. 2150  IF NOT BIG THEN RETURN'                    If WIDTH 80, all done, return
  216. 2160  GOSUB 3020'                                For WIDTH 40, wait to continue,
  217. 2170  GOSUB 1860'                                clear input prompt lines,
  218. 2180  RETURN'                                    then return
  219. 2190  '************************    DECODE ARRAY POINTERS FOR OUTER CIRCLE    ***
  220. 2200  FOR J=1 TO 4'                             Four faces touch any chosen face
  221. 2210      FACE(J)=VAL(MID$(OC$(F),J*2-1,1))'    Which four? Also, from each, the
  222. 2220      POSITION(J)=VAL(MID$(OC$(F),J*2,1))'  first of the three consecutive
  223. 2230  NEXT'                                     cubies closest to a chosen face
  224. 2240  RETURN
  225. 2250  '************************    PREPARE TO TURN OUTER CIRCLE    *************
  226. 2260  FOR J=1 TO 4'                             Four faces touch chosen face...
  227. 2270      FOR K=1 TO 3'                         ...with three consecutive cubies
  228. 2280  '                                         Set cubie value in holding cell
  229. 2290          HOLD((J-1)*3+K)=CUBIE(FACE(J),((POSITION(J)+K-2) MOD 8)+1,1)
  230. 2300  '                                         Turn highlight flags `on'
  231. 2310          CUBIE(FACE(J),((POSITION(J)+K-2) MOD 8)+1,2)=-1
  232. 2320      NEXT
  233. 2330  NEXT
  234. 2340  RETURN
  235. 2350  '************************    FINISH TURNING OUTER CIRCLE    **************
  236. 2360  FOR J=1 TO 4'                             Four faces touch chosen face...
  237. 2370      FOR K=1 TO 3'                         ...with three consecutive cubies
  238. 2380          CUBIE(FACE(((J+OSO) MOD 4)+1),((POSITION(((J+OSO) MOD 4)+1)+K-2)                MOD 8)+1,1)=HOLD((J-1)*3+K)'               New value of each cubie
  239. 2390          FOR DMI=1 TO 2'                            Associated names follow
  240. 2400              CUBIE$(FACE(((J+OSO) MOD 4)+1),((POSITION(((J+OSO) MOD 4)+1)                    +K-2) MOD 8)+1,DMI)=PLACE$(DMI,FIX((HOLD((J-1)*3+K)\10)))
  241. 2410          NEXT
  242. 2420      NEXT
  243. 2430  NEXT
  244. 2440  RETURN
  245. 2450  '************************    PREPARE TO TURN CHOSEN FACE    **************
  246. 2460  FOR P=1 TO 8'                  All cubies on chosen face except the center
  247. 2470      HOLD(12+P)=CUBIE(F,P,1)'               Put cubie value in holding cell
  248. 2480      CUBIE(F,P,2)=-1'                       Turn highlight flags `on'
  249. 2490  NEXT
  250. 2500  RETURN
  251. 2510  '************************    FINISH TURNING CHOSEN FACE   ****************
  252. 2520  FOR P=1 TO 8'                  All cubies on chosen face except the center
  253. 2530      CUBIE(F,P,1)=HOLD(13+((P+OSI)MOD 8))'          New value of each cubie
  254. 2540      FOR DMI=1 TO 2'                                Associated names follow
  255. 2550          CUBIE$(F,P,DMI)=PLACE$(DMI,FIX(CUBIE(F,P,1)\10))
  256. 2560      NEXT
  257. 2570  NEXT
  258. 2580  RETURN
  259. 2590  '************************    SET UP FRESH CUBE   *************************
  260. 2600  'Initialize cubie arrays to starting values
  261. 2610  FOR F = 1 TO 6'                                  Six faces on the cube
  262. 2620      FOR P = 0 TO 9'                              Nine cubies per face
  263. 2630          CUBIE(F,P,1)=F*10+P'                     Two digit code
  264. 2640          FOR DMI=1 TO 2'                          Associated face and color
  265. 2650              CUBIE$(F,P,DMI)=LEFT$(PLACE$(DMI,F),2)
  266. 2660          NEXT
  267. 2670       NEXT
  268. 2680  NEXT
  269. 2690  'Erase accumulated `twists so far'
  270. 2700  FOR K=1 TO AT
  271. 2710      TWISTSSOFAR$(K)=""'                          Erase each line
  272. 2720  NEXT
  273. 2730  AT=1'                                            Begin line index at 1
  274. 2740  RETURN
  275. 2750  '************************    WIDTH 40 PROMPT LINE RELOCATER   ************
  276. 2760  IF BIG THEN LOCATE 19,1 ELSE LOCATE 15,1'        Location of input prompt
  277. 2770  RETURN
  278. 2780  '************************    CLEAR SCREEN, PRINT INSTRUCTIONS   **********
  279. 2790  IF BIG THEN COLOR ,4:BG=3 ELSE BG=43'      Set background color, offsets
  280. 2800  CLS'                                       Clear screen
  281. 2810  LOCATE 1,1+BG:COLOR 1:PRINT TITLE$'        Use emphasis where needed
  282. 2820  LOCATE 3,3+BG:COLOR 7:PRINT"Each twist is called by the first"
  283. 2830  LOCATE 4,BG:PRINT"letter of the face you wish to twist:"
  284. 2840  LOCATE 5,BG:COLOR 1:PRINT"U";:COLOR 7:PRINT" for the upper face, ";             :COLOR 1:PRINT"L";:COLOR 7:PRINT" for the left"
  285. 2850  LOCATE 6,BG:PRINT"face, ";:COLOR 1:PRINT"F";:COLOR 7:                           :PRINT" for the front face, ";:COLOR 1:PRINT"R";:COLOR 7:PRINT" for the"
  286. 2860  LOCATE 7,BG:PRINT"right face, ";:COLOR 1:PRINT"B";:COLOR 7                      :PRINT" for the back face and ";:COLOR 1:PRINT"D":COLOR 7
  287. 2870  LOCATE 8,BG:PRINT"for the downward face. The twists will"
  288. 2880  LOCATE 9,BG:PRINT"be clockwise. To make a counterclock-"
  289. 2890  LOCATE 10,BG:PRINT"wise twist, the letter is followed by"
  290. 2900  LOCATE 11,BG:PRINT"a ";:COLOR 1:PRINT"'";:COLOR 7:PRINT" (e.g. ";               :COLOR 1:PRINT"L'";:COLOR 7:PRINT" ). To change the display,"
  291. 2910  LOCATE 12,BG:PRINT"enter either the word ";:COLOR 1:PRINT"Labels";              :COLOR 7:PRINT" or ";:COLOR 1:PRINT"Colors";:COLOR 7
  292. 2920  IF CLRMON THEN LOCATE 12,BG:PRINT"enter the word ";:COLOR 1:PRINT "Big";:                      COLOR 7:PRINT" or ";' Additional command for color monitors
  293. 2930  LOCATE 13,BG:PRINT"or ";:COLOR 1:PRINT"Faces";:COLOR 7:PRINT" or ";             :COLOR 1:PRINT"Codes";:COLOR 7:PRINT". Use ";:COLOR 1:PRINT"Skip";:COLOR 7      :PRINT" to resume/"
  294. 2940  LOCATE 14,BG:PRINT"skip verification. Use ";:COLOR 1:PRINT"New";:COLOR 7        :PRINT" to restart."
  295. 2950  IF NOT BIG THEN RETURN'            The following commands are for WIDTH 40
  296. 2960  LOCATE 15,3:PRINT "To accommodate those using television ";
  297. 2970  PRINT "  sets (i.e. confined to WIDTH 40), the ";
  298. 2980  PRINT "  commands ";:COLOR 1:PRINT "List";:COLOR 7:PRINT " & ";:COLOR 1
  299. 2990  PRINT "Help";:COLOR 7:PRINT " have been added."
  300. 3000  RETURN
  301. 3010  '************************    WAIT TO CONTINUE   **************************
  302. 3020  LOCATE 25,9:PRINT "Press the spacebar to continue";
  303. 3030  IF INKEY$<>" " THEN 3030
  304. 3040  LOCATE 25,3:COLOR 1,4:PRINT TITLE$;:COLOR 7,0:RETURN
  305. 3050  '************************    WIDTH 40 INPUT LIST    **********************
  306. 3060  LOCATE 1,19:COLOR BR(2),,BR(4):PRINT "Twists: ";
  307. 3070  FOR LI=1 TO 2:LOCATE LI,25+LI
  308. 3080      FOR TI=1 TO 3
  309. 3090          FOR DI=0 TO 1
  310. 3100              COLOR BR((LI-1)*3+TI)
  311. 3110              IF DI THEN PU$="!' " ELSE PU$="! "
  312. 3120              PRINT USING PU$;MID$(T$,(LI-1)*3+TI);
  313. 3130          NEXT
  314. 3140      NEXT
  315. 3150  NEXT
  316. 3160  LOCATE 4,31:COLOR BR(6):PRINT "Commands:";
  317. 3170  FOR CM=1 TO 9
  318. 3180      LOCATE 5+CM,35
  319. 3190      COLOR BR(CM MOD 6+1)
  320. 3200      PRINT DM$(CM)
  321. 3210  NEXT
  322. 3220  COLOR 7:RETURN
  323. 3230  '************************    READ CONSTANTS    ***************************
  324. 3240  FOR FACE=1 TO 6'                 Six faces
  325. 3250       READ PLACE$(1,FACE)'        Name and number each face
  326. 3260  NEXT
  327. 3270  DATA"upper","left","front","right","back","down"
  328. 3280  FOR FACE=1 TO 6'                If you have a cube that's used frequently,
  329. 3290       READ YOURS$(FACE)'         put the six names of its colors as data on
  330. 3300  NEXT'   line 3310 in proper (see line 3270) order. See REMark on line 4160
  331. 3310  DATA"white","orange","blue","red","green","yellow"
  332. 3320  FOR P=1 TO 8'                    Eight cubies surround the center cubie
  333. 3330      READ XOF(P),YOF(P)'          Offsets to locations of middle cubies for
  334. 3340  NEXT'                              each neighboring cubie on the same face
  335. 3350  DATA -1,-3,-1,0,-1,3,0,3,1,3,1,0,1,-3,0,-3
  336. 3360  FOR FA=1 TO 6'                   Six faces
  337. 3370     READ XBL(FA),YBL(FA)'         Locations of labels in WIDTH 40 mode
  338. 3380  NEXT
  339. 3390  DATA 2,4,13,3,4,19,13,19,13,27,17,17
  340. 3400  FOR FA=1 TO 6'                   Six faces
  341. 3410      READ REL(FA),RELY(FA)'       Offsets from old to new locations of the
  342. 3420  NEXT'                              middle cubies of each face
  343. 3430  DATA 1,2,3,0,3,2,3,4,3,6,5,2
  344. 3440  FOR F=1 TO 6'                    Six faces
  345. 3450     READ X(F),Y(F)'               Locations of middle cubies of each face
  346. 3460  NEXT
  347. 3470  DATA 2,14,6,4,6,14,6,24,6,34,10,14
  348. 3480  FOR F=1 TO 6'                    Six faces
  349. 3490     READ OC$(F)'  Codes with array indexes to outer circle around each face
  350. 3500  NEXT
  351. 3510  DATA "21514131","17376753","15476123","13576333","11276543","25354555"
  352. 3520  FOR DMI=1 TO 9'                  Nine recognized commands
  353. 3530     READ DM$(DMI)'                Valid display types and other commands
  354. 3540  NEXT
  355. 3550  DATA CODE,FACE,COLOR,LABEL,NEW,BIG,LIST,HELP,SKIP
  356. 3560  DIRECTION$(0)="clockwise":DIRECTION$(2)="counterclockwise"
  357. 3570  T$="ULFRBD"'                     Valid twist requests
  358. 3580  TWISTSSOFAR$(0)="The list of twists so far :"
  359. 3590  TITLE$=SPACE$(7)+"RUBIK'S CUBE SIMULATOR"+SPACE$(7)
  360. 3600  RETURN
  361. 3610  '************************    INITIALIZE VARIABLES    *********************
  362. 3620  DEF SEG=0'                                      Is color monitor present?
  363. 3630  IF (PEEK(&H410) AND &H30)<>&H30 THEN CLRMON=-1' If so, set CLRMON flag on
  364. 3640  DM=1'                                           Set display type for faces
  365. 3650  LABEL=-1'                                       Turn label flag on
  366. 3660  RETURN
  367. 3670  '************************    TITLE PAGE    *******************************
  368. 3680  IF CLRMON THEN COLOR 1,4:WIDTH 40:K=1 ELSE WIDTH 80:K=21
  369. 3690  CLS:LOCATE 3,2+K:PRINT TITLE$
  370. 3700  LOCATE 6,15+K:PRINT"PC MAGAZINE"
  371. 3710  LOCATE ,15+K:COLOR 7:PRINT"March, 1982"
  372. 3720  LOCATE 24,19+K:PRINT"press the spacebar";
  373. 3730  IF INKEY$<>" " THEN 3730
  374. 3740  COLOR 7,0
  375. 3750  RETURN
  376. 3760  '************************    INPUT A COLOR FOR EACH FACE    **************
  377. 3770  CLS
  378. 3780  LOCATE 2,7+K
  379. 3790  K$="*** COLORING THE CUBE ***"
  380. 3800  'Is color monitor present?
  381. 3810  IF CLRMON THEN 3880
  382. 3820  'For those using a monochrome monitor
  383. 3830  PRINT K$
  384. 3840  LOCATE 9,K+6
  385. 3850  PRINT"(The name of each color":PRINT SPC(11+K)"should begin with a":
  386. 3860  PRINT SPC(16+K)"different letter.)":GOTO 4080
  387. 3870  'For those using a color monitor
  388. 3880  FOR L=1 TO 25
  389. 3890      COLOR (L MOD 7)+1
  390. 3900      PRINT MID$(K$,L,1);
  391. 3910  NEXT
  392. 3920  LOCATE 4,4
  393. 3930  FOR C=1 TO 7'              Print a block of color and it's assigned number
  394. 3940      COLOR ,C
  395. 3950      PRINT "     ";
  396. 3960      COLOR C,0
  397. 3970      PRINT "---";C;
  398. 3980      PRINT SPC(10)
  399. 3990  NEXT
  400. 4000  LOCATE 9,1'                Print coloring directions
  401. 4010  COLOR 1,4
  402. 4020  PRINT "Choose each face's color by entering the";
  403. 4030  PRINT "appropriate number from the list above, ";
  404. 4040  COLOR 0,2
  405. 4050  PRINT "or just press [RETURN] for each face and";
  406. 4060  PRINT "the computer will choose the colors.    "
  407. 4070  'For everybody
  408. 4080  LOCATE 15,K
  409. 4090  COLOR 23,0:PRINT"Enter";
  410. 4100  COLOR 7:PRINT" a color for each face:"
  411. 4110  PRINT
  412. 4120  FOR FACE = 1 TO 6
  413. 4130      LOCATE FACE+16,15+K:COLOR 0,7:PRINT USING" \    \";PLACE$(1,FACE);
  414. 4140      COLOR 7,0:INPUT;" ";PLACE$(2,FACE)'   Semicolon before input prompt...
  415. 4150      IF CLRMON THEN 4190'                  ...suppresses the usual linefeed
  416. 4160      IF PLACE$(2,FACE)="" THEN PLACE$(2,FACE)=YOURS$(FACE)'See REMarks from lines 3280-3300 to name colors by default (null input) for frequently used cube
  417. 4170      GOTO 4240
  418. 4180  'Again, for those using color
  419. 4190      IF PLACE$(2,FACE)="" THEN BR(FACE)=FACE:GOTO 4220                               ELSE BR(FACE)=VAL(PLACE$(2,FACE))
  420. 4200      IF BR(FACE)<1 OR BR(FACE)>7 THEN LOCATE ,26:PRINT SPC(14):GOTO 4130
  421. 4210      IF ASC(PLACE$(2,FACE))<56 THEN PLACE$(2,FACE)=MID$(PLACE$(2,FACE),2)
  422. 4220      COLOR 7,0:LOCATE ,24:PRINT "= ";'        Print `=' over question mark
  423. 4230      COLOR 0,BR(FACE):PRINT PLACE$(2,FACE)+"     " 'Print name and block of
  424. 4240  NEXT'                                                       selected color
  425. 4250  'And finally, again for everybody
  426. 4260  COLOR 7,0'                                      Normalize color and
  427. 4270  LOCATE 15,K:PRINT "*Chosen ";'                  Write over blinking prompt
  428. 4280  LOCATE 9,K'                           This writes over coloring directions
  429. 4290  COLOR 1,4
  430. 4300  PRINT "  Check each face and its chosen color. ";
  431. 4310  COLOR 7,0
  432. 4320  PRINT SPC(79)" ";
  433. 4330  LOCATE 11,K
  434. 4340  COLOR 5,2
  435. 4350  PRINT "Press the spacebar to start over...  or,";
  436. 4360  COLOR ,0
  437. 4370  PRINT SPC(79)" ";
  438. 4380  LOCATE 99ation
  439. 200  COLOR 23'                                  Blink ...
  440. 210  PRINT "Enter ";'                              ... beginning of input prompt
  441. 220  COLOR 7'                                   Normal foreground
  442. 230  LINE INPUT "a twist or command: ",TWIST$'  Finish prom
  443.